package com.it.you;

import com.it.you.common.utils.IpUtil;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;
import javax.servlet.http.HttpServletRequest;

@RestController
@Slf4j
public class YouController {

    @RequestMapping(value ="/you",method = RequestMethod.GET)
    public String test(HttpServletRequest request) {
        //获取ip
        String ip = IpUtil.getIpAddress(request);
        if (StringUtils.isNotBlank(ip)) {
            String[] ipAttr = ip.split(",");
            ip = ipAttr[0]; //取第一个客户的ip
        }
        return "youhui" + ip;
    }

}
